package com.lanou.activity.Service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.activity.Service.LimitService;
import com.lanou.activity.mapper.LimitMapper;
import com.lanou.activity.utils.Constant;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class LimitServiceImpl implements LimitService{

    @Resource
    private LimitMapper limitMapper;

    /**
     * @description 添加 限额信息表的数据
     * @author Lonely
     * @date 17/9/23
     * @return
     * @param
     */
    @Override
    public int addLimitInfo(Map<String, Object> params) {
        return limitMapper.insertLimitInfo(params);
    }

    @Override
    public PageInfo<Map<String, Object>> selectLmtByPageList(Map<String, Object> params) {
        Integer currentPage = params.get("currentPage") == null ? 1 : Integer.parseInt((String) params.get("currentPage"));
        PageHelper.startPage(currentPage, Constant.CURRENTPAGE);
        List<Map<String, Object>> list = limitMapper.selectLmtByPageList(params);
        return new PageInfo<Map<String, Object>>(list);
    }

    @Override
    public List<Map<String, Object>> selectLmtById(Integer id) {
        return limitMapper.selectLmtById(id);
    }

    @Override
    public int updateLmt(Map<String, Object> params) {
        return  limitMapper.updateLmt(params);
    }
}
